package com.xiaocq.todo.components;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import com.xiaocq.todo.components.TodoMeta.TableMeta;

public class DatabaseHelper extends SQLiteOpenHelper{
	private static final String TAG = "DatabaseHelper";
	public static final String DATABASE_NAME = "todos.db";
	public static final String TABLE_NAME = "todos";
	public static final int VERSION = 1;
	
	public DatabaseHelper(Context context){
		super(context, DATABASE_NAME, null, VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		String createSQL = "CREATE TABLE " + TABLE_NAME + " (" + TableMeta._ID + " INTEGER PRIMARY KEY,"
				+ TableMeta.TITLE + " TEXT," + TableMeta.TIP_DATE + " INTEGER," + TableMeta.START_TIME + " TEXT,"
				+ TableMeta.FINISH_TIME + " TEXT," + TableMeta.ISALARM + " INTEGER);";
		Log.d(TAG, createSQL);
		db.execSQL(createSQL);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		//do something
	}

}
